home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Champak 52
/
Volume 52 - JOGO DISK .iso
/
Games
/
shopdrop.swf
/
scripts
/
__Packages
/
ShopHandler.as
< prev
next >
Wrap
Text File
|
2007-09-27
|
2KB
|
73 lines
class ShopHandler
{
var scrollSpeed = 200;
var buildingSpace = 260;
var nBuildings = 64;
var cBuildings = 0;
function ShopHandler(loc)
{
this.aClips = [];
this.location = loc;
this.lastBuilding = this.addClip("mcBuildingLeft");
this.render();
}
function update(nElapsed)
{
var _loc5_ = this.scrollSpeed * nElapsed;
var _loc4_ = this.aClips;
var _loc6_ = _loc4_.length;
var _loc3_ = undefined;
var _loc2_ = 0;
while(_loc2_ < _loc6_)
{
_loc3_ = _loc4_[_loc2_];
if(_loc3_ != null)
{
_loc3_.pos.x += _loc5_;
}
_loc2_ = _loc2_ + 1;
}
if(this.lastBuilding.pos.z > this.buildingSpace)
{
this.lastBuilding = this.addClip("mcBuildingLeft");
}
}
function render()
{
var _loc4_ = this.aClips;
var _loc5_ = _loc4_.length;
var _loc3_ = undefined;
var _loc2_ = 0;
while(_loc2_ < _loc5_)
{
_loc3_ = _loc4_[_loc2_];
if(_loc3_ != null)
{
_loc3_.render();
}
_loc2_ = _loc2_ + 1;
}
}
function addClip(sId)
{
var _loc3_ = this.aClips.length;
this.cBuildings = ++this.cBuildings % this.nBuildings;
var _loc2_ = this.location.attachMovie(sId,"clip" + this.cBuildings,_loc3_);
_loc2_.handler = this;
_loc2_.render();
this.aClips.push(_loc2_);
return _loc2_;
}
function removeClip(clip)
{
this.aClips.splice(0,1);
clip.removeMovieClip();
var _loc2_ = 0;
while(_loc2_ < this.aClips.length)
{
this.aClips[_loc2_].swapDepths(_loc2_);
_loc2_ = _loc2_ + 1;
}
}
}